import selenium
from selenium import webdriver
import requests as http
import json
from config import getOrderNumsConfig


def getOrderNums(c):
    print('开始获取订单号')
    api = 'http://192.168.5.158/Order/GetJDOrderList'
    res = http.post(url=api, json=c)
    if res.status_code == 200:
        r = json.loads(res.text)
        print(r)
        # 获取订单列表
        return r['data']


def runMain():
    print('开始运行新项目')
    api = 'https://order.jd.com/center/list.action'
    # 登陆jd，前往订单列表
    web = webdriver.Chrome()
    web.get(api)

    orderList = getOrderNums(getOrderNumsConfig)
    print('一共获取到%d个订单号' % len(orderList))
    for key in orderList:
        print(f'key -->> {key}')
        orderNumber = orderList[key]['outOrderNumber']
        print(f'此次订单号为：{orderNumber}')
        # 前往jd订单列表查看物流记录

        pass


if __name__ == "__main__":
    runMain()
